//
//  ALPHotRecommendsSecondCell.m
//  AlpFM
//
//  Created by dllo on 16/1/27.
//  Copyright © 2016年 Alp. All rights reserved.
//

#import "ALPHotRecommendsSecondCell.h"
#import "ALPHotRecommendsControllerCell.h"
#import "ALPHotRecommendsThreeModel.h"

@interface ALPHotRecommendsSecondCell ()<UICollectionViewDataSource,UICollectionViewDelegate>
@property (nonatomic, strong) UILabel *title;
@property (nonatomic, strong) UIImageView *sanjiao; //三角图标
@property (nonatomic, strong) UICollectionView *myCollection;
@end

@implementation ALPHotRecommendsSecondCell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self creat];
    }
    return self;
}
-(void)creat{
    self.sanjiao = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 16, 16)];
    self.sanjiao.image = [UIImage imageNamed:@"sanjiao"];
    [self.contentView addSubview:self.sanjiao];
    
    self.title = [[UILabel alloc]initWithFrame:CGRectMake(35, 9, 100, 20)];
    self.title.font = [UIFont boldSystemFontOfSize:16];
    self.title.textColor = [UIColor grayColor];
    [self.contentView addSubview:self.title];
    
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init];
    flowLayout.itemSize = CGSizeMake(111.7, 180);
    flowLayout.sectionInset = UIEdgeInsetsMake(0, 10, 0, 10);
    flowLayout.minimumLineSpacing = 10;  //列间隙
    flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    self.myCollection = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 30, 375, 170) collectionViewLayout:flowLayout];
    self.myCollection.delegate = self;
    self.myCollection.dataSource = self;
    self.myCollection.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.myCollection];
    
    [self.myCollection registerClass:[ALPHotRecommendsControllerCell class] forCellWithReuseIdentifier:@"cell"];
    
    
}

-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return _two.list.count;
}

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    ALPHotRecommendsControllerCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
    cell.model = _two.list[indexPath.row];
    return cell;
}


-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    
    ALPHotRecommendsThreeModel *mol = [_two.list objectAtIndex:indexPath.row];
    [self.xieyiren sengMessageidid:mol.albumId indexPath:indexPath.row + 1 jishu:mol.tracks];
    
}





-(void)setTwo:(ALPHotRecommendsSecondModel *)two{
    _two = two;
    self.title.text = _two.title;
    [self.myCollection reloadData];
}













- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
